﻿/********************************************************
 * 类名： GoodsCategoryBLL.cs
 * 功能： 商品业务层
 *   ver	变更日		作者			变更内容
 * ────────────────────────────────────────
 *   V01.0	2013-11-27	李波			初版
 *
 * Copyright (c) 2013，李波版权所有
 ********************************************************/
using System;
using System.Collections;
using PSS.DAL.SetManage.AuxiliaryInfo;
using PSS.Entity;
using PSS.Entity.SetManage.AuxiliaryInfo;
using PSS.Utility;

namespace PSS.BLL.SetManage.AuxiliaryInfo
{
    public class GoodsCategoryBLL
    {
        private readonly GoodsCategoryDAL _dal = new GoodsCategoryDAL();
        public string GetGoodsCategoryList(Pagination qcmodel)
        {
            var total = _dal.GetTotal();
            var list = _dal.GetGoodsCategoryList(qcmodel);
            return JsonHelper.Encode(total, list);
        }
        public string GetGoodsCategoryListByCombobox()
        {
            return JsonHelper.Encode(_dal.GetGoodsCategoryListByCombobox());
        }
        public bool ModifyGoodsCategory(string data)
        {
            var model = new GoodsCategoryEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.GCategoryId = new Guid(row["GCategoryId"].ToString());
                model.GCategoryName = row["GCategoryName"].ToString();
            }
            return _dal.ModifyGoodsCategory(model);
        }
        public bool AddGoodsCategory(string data)
        {
            var model = new GoodsCategoryEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.GCategoryId = Guid.NewGuid();
                model.GCategoryName = row["GCategoryName"].ToString();
            }
            return _dal.AddGoodsCategory(model);
        }
        public string GetGoodsCategoryInfo(string id)
        {
            return JsonHelper.Encode(_dal.GetGoodsCategoryInfo(id));
        }
        public bool RemoveGoodsCategory(string id)
        {
            return _dal.RemoveGoodsCategory(id);
        }
    }
}
